package com.group.project.hrms.service.impl;

import com.group.project.hrms.entity.SalaryBaseBasic;
import com.group.project.hrms.mapper.SalaryBaseBasicMapper;
import com.group.project.hrms.service.ISalaryBaseBasicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class SalaryBaseBasicService implements ISalaryBaseBasicService {

    @Autowired
    private SalaryBaseBasicMapper salaryBaseBasicMapper;


    @Override
    public int insertSalaryBaseBasic(SalaryBaseBasic salaryBaseBasic) {
        return salaryBaseBasicMapper.insert(salaryBaseBasic);
    }

    @Override
    public int deleteSalaryBaseBasic(SalaryBaseBasic salaryBaseBasic) {
        return salaryBaseBasicMapper.deleteByPrimaryKey(salaryBaseBasic);
    }

    @Override
    public int updateSalaryBaseBasic(SalaryBaseBasic salaryBaseBasic) {
        return salaryBaseBasicMapper.updateByPrimaryKey(salaryBaseBasic);
    }

    @Override
    public SalaryBaseBasic selectOneSalaryBaseBasic(SalaryBaseBasic salaryBaseBasic) {
        return null;
    }

    @Override
    public SalaryBaseBasic selectOneSalaryBaseBasicByFileMonthAndContactID(String fileMonth, String cid) {
        Example example = new Example(SalaryBaseBasic.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andLike("monthFlag", "%" + fileMonth + "%");
        criteria.andEqualTo("contactId", cid);
        return salaryBaseBasicMapper.selectOneByExample(example);
    }

    @Override
    public List<SalaryBaseBasic> selectSalaryBaseBasicByMonth(String month) { //month: 2022-06
        Example example = new Example(SalaryBaseBasic.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.orLike("monthFlag", "%" + month + "%");
        return salaryBaseBasicMapper.selectByExample(example);
    }

    @Override
    public List<SalaryBaseBasic> selectAllSalaryBaseBasic() {
        return salaryBaseBasicMapper.selectAll();
    }
}
